clear;
clc;
close all;
addpath('../02_functions');

%------------------------------------------------------------------------%
% This file creates figure 11 in the paper 
%------------------------------------------------------------------------%


% choose sample period ---------------------------------------------------------------------------------- %

start_date              = datenum(2004,1,5); 
finish_date             = datenum(2020,12,29);

winsorizing             = 0;
alpha                   = 0.99;
replace_option          = 1;

file_name               = '../01_data/es_quotes_5minute_EST';
results                 = make_returns_288(file_name,start_date,finish_date,winsorizing,alpha,replace_option);
return_AD               = results.return_AD;
log_return_AD           = results.log_return_AD;
T                       = results.T;
caldt                   = results.caldt;

% Compute returns------------------------------------------------------------------------------- %

file_name               = 'es_quotes_5minute_EST.mat';
data_quotes             = load(strcat('../01_Data/',file_name));

beg                     = find_closest(data_quotes.caldt_daily,start_date);
fin                     = find_closest(data_quotes.caldt_daily,finish_date);
    
caldt                   = data_quotes.caldt_daily(beg:fin);
log_Bid_price_last      = log(data_quotes.BID_mat);
Bid_price_last          = data_quotes.BID_mat;
log_Ask_price_last      = log(data_quotes.ASK_mat);
Ask_price_last          = data_quotes.ASK_mat;
log_Mid_price_last      = log(data_quotes.MID_mat);
Mid_price_last          = data_quotes.MID_mat;

% Define time periods of interest:
ODIndex_start               = 96;         % 02:00 
ODIndex_end                 = 108;        % 03:00 
log_return_OD_TC            = log_Bid_price_last(beg:fin,ODIndex_end) - log_Ask_price_last(beg:fin,ODIndex_start); 

ODIndex_start               = 96;         % 02:00 
ODIndex_end                 = 108;        % 03:00 
return_OD_TC                = (Bid_price_last(beg:fin,ODIndex_end) - Ask_price_last(beg:fin,ODIndex_start))./Ask_price_last(beg:fin,ODIndex_start); 

ODIndex_start               = 96;         % 02:00 
ODIndex_end                 = 108;        % 03:00 
log_return_OD               = log_Mid_price_last(beg:fin,ODIndex_end) - log_Mid_price_last(beg:fin,ODIndex_start); 

ODIndex_start               = 96;         % 02:00 
ODIndex_end                 = 108;        % 03:00 
return_OD                   = (Mid_price_last(beg:fin,ODIndex_end) - Mid_price_last(beg:fin,ODIndex_start))./Mid_price_last(beg:fin,ODIndex_start); 

ODIndex_start               = 90;         % 01:30 
ODIndex_end                 = 114;        % 03:30 
log_return_OD_extended_TC   = log_Bid_price_last(beg:fin,ODIndex_end) - log_Ask_price_last(beg:fin,ODIndex_start); 

ODIndex_start               = 90;         % 01:30 
ODIndex_end                 = 114;        % 03:30 
return_OD_extended_TC       = (Bid_price_last(beg:fin,ODIndex_end) - Ask_price_last(beg:fin,ODIndex_start))./Ask_price_last(beg:fin,ODIndex_start); 

ODIndex_start               = 90;         % 01:30 
ODIndex_end                 = 114;        % 03:30 
log_return_OD_extended      = log_Mid_price_last(beg:fin,ODIndex_end) - log_Mid_price_last(beg:fin,ODIndex_start); 

ODIndex_start               = 90;         % 01:30 
ODIndex_end                 = 114;        % 03:30 
return_OD_extended          = (Mid_price_last(beg:fin,ODIndex_end) - Mid_price_last(beg:fin,ODIndex_start))./Mid_price_last(beg:fin,ODIndex_start); 

IDIndex_start               = 186;        % 09:30
IDIndex_end                 = 267;        % 16:15
log_return_OTC_TC           = log_Bid_price_last(beg:fin,IDIndex_end) - log_Ask_price_last(beg:fin,IDIndex_start); 

IDIndex_start               = 186;        % 09:30
IDIndex_end                 = 267;        % 16:15
return_OTC_TC               = (Bid_price_last(beg:fin,IDIndex_end) - Ask_price_last(beg:fin,IDIndex_start))./Ask_price_last(beg:fin,IDIndex_start); 

IDIndex_start               = 186;        % 09:30
IDIndex_end                 = 267;        % 16:15
log_return_OTC              = log_Mid_price_last(beg:fin,IDIndex_end) - log_Mid_price_last(beg:fin,IDIndex_start); 

IDIndex_start               = 186;        % 09:30
IDIndex_end                 = 267;        % 16:15
return_OTC                  = (Mid_price_last(beg:fin,IDIndex_end) - Mid_price_last(beg:fin,IDIndex_start))./Mid_price_last(beg:fin,IDIndex_start); 

ONIndex_start               = 267;      % 16:15
ONIndex_end                 = 186;      % 09:30
log_return_CTO_TC           = log_Bid_price_last(beg:fin,ONIndex_end) - log_Ask_price_last(beg-1:fin-1,ONIndex_start); 

ONIndex_start               = 267;      % 16:15
ONIndex_end                 = 186;      % 09:30
return_CTO_TC               = (Bid_price_last(beg:fin,ONIndex_end) - Ask_price_last(beg-1:fin-1,ONIndex_start))./Ask_price_last(beg-1:fin-1,ONIndex_start); 

ONIndex_start               = 267;      % 16:15
ONIndex_end                 = 186;      % 09:30
log_return_CTO              = log_Mid_price_last(beg:fin,ONIndex_end) - log_Mid_price_last(beg-1:fin-1,ONIndex_start); 

ONIndex_start               = 267;      % 16:15
ONIndex_end                 = 186;      % 09:30
return_CTO                  = (Mid_price_last(beg:fin,ONIndex_end) - Mid_price_last(beg-1:fin-1,ONIndex_start))./Mid_price_last(beg-1:fin-1,ONIndex_start); 

ONIndex_start               = 267;      % 16:15
ONIndex_end                 = 267;          % 09:30
log_return_CTC              = log_Mid_price_last(beg:fin,ONIndex_end) - log_Mid_price_last(beg-1:fin-1,ONIndex_start); 

ONIndex_start               = 267;      % 16:15
ONIndex_end                 = 267;      % 09:30
return_CTC                  = (Mid_price_last(beg:fin,ONIndex_end) - Mid_price_last(beg-1:fin-1,ONIndex_start))./Mid_price_last(beg-1:fin-1,ONIndex_start); 

OpenIndex_start = 174;      % 08:30 
OpenIndex_end = 192;        % 10:00 
log_return_short_Open_TC    = log_Bid_price_last(:,OpenIndex_start) - log_Ask_price_last(:,OpenIndex_end); 

OpenIndex_start             = 174;      % 08:30 
OpenIndex_end               = 192;      % 10:00 
return_short_Open_TC        = (Bid_price_last(:,OpenIndex_start) - Ask_price_last(:,OpenIndex_end))./Ask_price_last(:,OpenIndex_end); 

OpenIndex_start             = 174;      % 08:30 
OpenIndex_end               = 192;      % 10:00 
log_return_short_Open       = log_Mid_price_last(:,OpenIndex_start) - log_Mid_price_last(:,OpenIndex_end); 

OpenIndex_start             = 174;      % 08:30 
OpenIndex_end               = 192;      % 10:00 
return_short_Open           = (Mid_price_last(:,OpenIndex_start) - Mid_price_last(:,OpenIndex_end))./Mid_price_last(:,OpenIndex_end); 

% Risk-free returns (from 4 week Treasury Bills------------------------------------------------------------------------------- %

[num,txt,raw] =  xlsread('../01_Data/CRSP_DAILY_4WK_RF_V4.xlsx');

yield               = num(:,4);
dates_yield         = num(:,1)+693960;

beg_rf              = find_closest(dates_yield,start_date);
fin_rf              = find_closest(dates_yield,finish_date);

dates_yield_plot    = dates_yield(beg_rf:fin_rf);
ann_rf_return       = exp(365*yield) - 1  ;
daily_rf_return     = ann_rf_return/365;
daily_rf_return     = daily_rf_return(beg_rf:fin_rf);
cum_return_rf       = cumprod(1+daily_rf_return);
cum_return_rf       = cum_return_rf./cum_return_rf(1);

% ----------------------------------------------------------------% 
% LOAD TRADES
% ----------------------------------------------------------------% 

data_trades = load('../01_Data/es_trades_5minute_EST.mat');

No_trades                                           = data_trades.trades_per_min_mat;
No_contracts                                        = data_trades.trade_quantity_per_min_mat;
Signed_volume                                       = data_trades.signed_vol_per_min_mat;

beg_TRADES                                          = find_closest(data_trades.caldt_daily,start_date);
fin_TRADES                                          = find_closest(data_trades.caldt_daily,finish_date);

caldt_trades                                        = data_trades.caldt_daily(beg_TRADES:fin_TRADES);
No_trades                                           = No_trades(beg_TRADES:fin_TRADES,:);
Volume                                              = No_contracts(beg_TRADES:fin_TRADES,:);
Signed_volume                                       = Signed_volume(beg_TRADES:fin_TRADES,:);

% INTERSECT
[C,IA,IB]                                           = intersect(caldt_trades,caldt);
caldt                                               = caldt(IB);
log_return_AD                                       = log_return_AD(IB,:);
return_AD                                           = return_AD(IB,:);

log_return_OD_TC                                    = log_return_OD_TC(IB,:);
return_OD_TC                                        = return_OD_TC(IB,:);
log_return_OD                                       = log_return_OD(IB,:);
return_OD                                           = return_OD(IB,:);

log_return_OD_extended_TC                           = log_return_OD_extended_TC(IB,:);
return_OD_extended_TC                               = return_OD_extended_TC(IB,:);
log_return_OD_extended                              = log_return_OD_extended(IB,:);
return_OD_extended                                  = return_OD_extended(IB,:);

log_return_OTC_TC                                   = log_return_OTC_TC(IB,:);
return_OTC_TC                                       = return_OTC_TC(IB,:);
log_return_OTC                                      = log_return_OTC(IB,:);
return_OTC                                          = return_OTC(IB,:);

log_return_CTO_TC                                   = log_return_CTO_TC(IB,:);
return_CTO_TC                                       = return_CTO_TC(IB,:);
log_return_CTO                                      = log_return_CTO(IB,:);
return_CTO                                          = return_CTO(IB,:);

log_return_CTC                                      = log_return_CTC(IB,:);
return_CTC                                          = return_CTC(IB,:);

log_return_short_Open_TC                            = log_return_short_Open_TC(IB,:);
return_short_Open_TC                                = return_short_Open_TC(IB,:);
log_return_short_Open                               = log_return_short_Open(IB,:);
return_short_Open                                   = return_short_Open(IB,:);

caldt_trades                                        = caldt_trades(IA);
No_trades                                           = No_trades(IA,:);
Volume                                              = Volume(IA,:);
Signed_volume                                       = Signed_volume(IA,:);


% ----------------------------------------------------------------%
% % Load VIX indices
% ----------------------------------------------------------------%

file_name               = '../01_data/VIX_index_5min_EST.mat';
data_VIX                = load(file_name);

beg                     = find_closest(data_VIX.caldt_daily,start_date);
fin                     = find_closest(data_VIX.caldt_daily,finish_date);

caldt_VIX               = data_VIX.caldt_daily(beg:fin);
caldt_VIX_mat           = data_VIX.caldt_mat(beg:fin,:);
VIX                     = data_VIX.price_mat(beg:fin,:);

indx_beg                = find(hour(caldt_VIX_mat(1,:)) == 9 & minute(caldt_VIX_mat(1,:)) == 00);
indx_fin                = find(hour(caldt_VIX_mat(1,:)) == 16 & minute(caldt_VIX_mat(1,:)) == 15);
scaldt_ID               = caldt_VIX_mat(1,indx_beg:indx_fin);
caldt_ID.Format         = 'HH:mm';
VIX                     = VIX(:,indx_beg:indx_fin);

VIX_open                = VIX(:,1);
VIX_close               = VIX(:,end);

VIX_change1             = VIX_open(2:end) - VIX_close(1:end-1);
VIX_change2             = VIX_close(2:end) - VIX_open(2:end);
VIX_change3             = VIX_close(2:end) - VIX_close(1:end-1);
VIX                     = VIX_close;
caldt_VIX               = caldt_VIX(2:end,1);

% INTERSECT
[C,IA,IB]               = intersect(caldt_VIX,caldt);
caldt                   = caldt(IB);
log_return_AD           = log_return_AD(IB,:);
return_AD               = return_AD(IB,:);

log_return_OD_TC            = log_return_OD_TC(IB,:);
return_OD_TC                = return_OD_TC(IB,:);
log_return_OD               = log_return_OD(IB,:);
return_OD                   = return_OD(IB,:);

log_return_OD_extended_TC   = log_return_OD_extended_TC(IB,:);
return_OD_extended_TC       = return_OD_extended_TC(IB,:);
log_return_OD_extended      = log_return_OD_extended(IB,:);
return_OD_extended          = return_OD_extended(IB,:);

log_return_OTC_TC           = log_return_OTC_TC(IB,:);
return_OTC_TC               = return_OTC_TC(IB,:);
log_return_OTC              = log_return_OTC(IB,:);
return_OTC                  = return_OTC(IB,:);

log_return_CTO_TC           = log_return_CTO_TC(IB,:);
return_CTO_TC               = return_CTO_TC(IB,:);
log_return_CTO              = log_return_CTO(IB,:);
return_CTO                  = return_CTO(IB,:);

log_return_CTC              = log_return_CTC(IB,:);
return_CTC                  = return_CTC(IB,:);

log_return_short_Open_TC    = log_return_short_Open_TC(IB,:);
return_short_Open_TC        = return_short_Open_TC(IB,:);
log_return_short_Open       = log_return_short_Open(IB,:);
return_short_Open           = return_short_Open(IB,:);

caldt_trades                = caldt_trades(IB);
No_trades                   = No_trades(IB,:);
Volume                      = Volume(IB,:);
Signed_volume               = Signed_volume(IB,:);

caldt_VIX                   = caldt_VIX(IA,1);
VIX                         = VIX(IA,1);
VIX_change1                 = VIX_change1(IA,1);
VIX_change2                 = VIX_change2(IA,1);
VIX_change3                 = VIX_change3(IA,1);

% ----------------------------------------------------------------% 
% % COMPUTE RETURNS
% ----------------------------------------------------------------% 

% 15 min intervals
% 15 minute log returns
indx                        = [3 : 3 : length(Signed_volume(1,:))];
indx_loop                   = [0 , indx];
Signed_volume_15b15_AD      = nan(size(Signed_volume,1),24*4);
Volume_15b15_AD             = nan(size(Volume,1),24*4);

for H = 1 : round(length(Signed_volume(1,:))/12*4)
    Signed_volume_15b15_AD(:,H)         = sum(Signed_volume(:,indx_loop(H)+1 : indx_loop(H+1)),2);
    Volume_15b15_AD(:,H)                = sum(Volume(:,indx_loop(H)+1 : indx_loop(H+1)),2);
end

lead = 1;

sum_signedVol_start                 = 86;
sum_signedVol_end                   = 89;

log_return_OD                       = log_return_OD(1+lead:end);
log_return_OD_extended              = log_return_OD_extended(1+lead:end);
log_return_OTC                      = log_return_OTC(1+lead:end);
log_return_CTO                      = log_return_CTO(1+lead:end);
log_return_CTC                      = log_return_CTC(1+lead:end);
log_return_short_Open               = log_return_short_Open(1+lead:end);

return_OD                           = return_OD(1+lead:end);
return_OD_extended                  = return_OD_extended(1+lead:end);
return_OTC                          = return_OTC(1+lead:end);
return_CTO                          = return_CTO(1+lead:end);
return_CTC                          = return_CTC(1+lead:end);
return_short_Open                   = return_short_Open(1+lead:end);

log_return_OD_TC                    = log_return_OD_TC(1+lead:end);
log_return_OD_extended_TC           = log_return_OD_extended_TC(1+lead:end);
log_return_OTC_TC                   = log_return_OTC_TC(1+lead:end);
log_return_CTO_TC                   = log_return_CTO_TC(1+lead:end);
log_return_short_Open_TC            = log_return_short_Open_TC(1+lead:end);

return_OD_TC                        = return_OD_TC(1+lead:end);
return_OD_extended_TC               = return_OD_extended_TC(1+lead:end);
return_OTC_TC                       = return_OTC_TC(1+lead:end);
return_CTO_TC                       = return_CTO_TC(1+lead:end);
return_short_Open_TC                = return_short_Open_TC(1+lead:end);

log_return_OD_extended_sort_lead_TC = log_return_OD_extended_TC;
return_OD_extended_sort_lead_TC     = return_OD_extended_TC;
log_return_OD_extended_sort_lead    = log_return_OD_extended;
return_OD_extended_sort_lead        = return_OD_extended;

close_signed_volume_lead            = sum(Signed_volume_15b15_AD(1:end-lead,sum_signedVol_start:sum_signedVol_end),2);
close_rel_signed_volume_lead        = sum(Signed_volume_15b15_AD(1:end-lead,sum_signedVol_start:sum_signedVol_end),2)./sum(Volume_15b15_AD(1:end-lead,sum_signedVol_start:sum_signedVol_end),2);
caldt_true_lead                     = caldt(1+lead:end);

caldt_true                          = caldt;
close_signed_volume                 = sum(Signed_volume_15b15_AD(:,sum_signedVol_start:sum_signedVol_end),2);
close_rel_signed_volume             = sum(Signed_volume_15b15_AD(:,sum_signedVol_start:sum_signedVol_end),2)./sum(Volume_15b15_AD(:,sum_signedVol_start:sum_signedVol_end),2);

VIX_change_lead                     = VIX_change3(1:end-lead);

%% strategies
indx_strat1                 = find(close_rel_signed_volume_lead < 0);
indx_strat2                 = find(VIX_change_lead > 0);
indx_strat3                 = find(close_rel_signed_volume_lead < 0 & VIX_change_lead > 0);

reg                         = fitlm(close_rel_signed_volume_lead,VIX_change_lead,'linear','Intercept',false);
b_coeff                     = table2array(reg.Coefficients(1,1));
indx_strat4                 = find(VIX_change_lead > -b_coeff*close_rel_signed_volume_lead);

reg2                        = fitlm(close_rel_signed_volume_lead,VIX_change_lead,'linear');
a_coeff                     = table2array(reg2.Coefficients(1,1));
b_coeff2                    = table2array(reg2.Coefficients(2,1));
indx_strat5                 = find(VIX_change_lead > -b_coeff2*close_rel_signed_volume_lead+a_coeff);
cccc                        = -1/b_coeff;

indx_strat9                 = find(VIX_change_lead > 100*close_rel_signed_volume_lead);

% ----------------------------------------------------------------% 
% Sorts
% ----------------------------------------------------------------% 


% find the days where we go long:

indx_B1                                 = indx_strat1;
indx_B2                                 = indx_strat2;
indx_B9                                 = indx_strat9;

percentage1                             = 100*length(indx_B1)/length(VIX_change_lead)
percentage2                             = 100*length(indx_B2)/length(VIX_change_lead)
percentage3                             = 100*length(indx_B9)/length(VIX_change_lead)

cum_return_CTC                          = cumprod(1+return_CTC);
cum_return_CTO                          = cumprod(1+return_CTO);
cum_return_OTC                          = cumprod(1+return_OTC);

cum_return_OR_short                     = cumprod(1+return_short_Open);
cum_return_OD                           = cumprod(1+return_OD);
cum_return_OD_extended                  = cumprod(1+return_OD_extended);

return_OD_TC                            = exp(log_return_OD_TC)-1;
cum_return_OD_TC                        = cumprod(1+return_OD_TC);

return_OD_extended_TC                   = exp(log_return_OD_extended_TC)-1;
cum_return_OD_extended_TC               = cumprod(1+return_OD_extended_TC);

return_CTO_TC                           = exp(log_return_CTO_TC)-1;
cum_return_CTO_TC                       = cumprod(1+return_CTO_TC);

return_OTC_TC                           = exp(log_return_OTC_TC)-1;
cum_return_OTC_TC                       = cumprod(1+return_OTC_TC);

return_short_Open_TC                    = exp(log_return_short_Open_TC)-1;
cum_return_short_Open_TC                = cumprod(1+return_short_Open_TC);

return_OD_sort_lead_RSV                 = return_OD_extended_sort_lead;
return_OD_long_RSV                      = zeros(size(return_OD_extended_sort_lead));
return_OD_long_RSV(indx_B1)             = return_OD_sort_lead_RSV(indx_B1);
cum_return_OD_long_RSV                  = cumprod(1+return_OD_long_RSV);
log_return_OD_long_RSV                  = zeros(size(log_return_OD_extended_sort_lead));
log_return_OD_long_RSV(indx_B1)         = log_return_OD_extended_sort_lead(indx_B1);

return_OD_sort_lead_TC_RSV              = return_OD_extended_sort_lead_TC;
return_OD_long_TC_RSV                   = zeros(size(return_OD_extended_sort_lead_TC));
return_OD_long_TC_RSV(indx_B1)          = return_OD_sort_lead_TC_RSV(indx_B1);
cum_return_OD_long_TC_RSV               = cumprod(1+return_OD_long_TC_RSV);
log_return_OD_long_TC_RSV               = zeros(size(log_return_OD_extended_sort_lead_TC));
log_return_OD_long_TC_RSV(indx_B1)      = log_return_OD_extended_sort_lead_TC(indx_B1);

return_OD_sort_lead_VIX                 = return_OD_extended_sort_lead;
return_OD_long_VIX                      = zeros(size(return_OD_extended_sort_lead));
return_OD_long_VIX(indx_B2)             = return_OD_sort_lead_VIX(indx_B2);
cum_return_OD_long_VIX                  = cumprod(1+return_OD_long_VIX);
log_return_OD_long_VIX                  = zeros(size(log_return_OD_extended_sort_lead));
log_return_OD_long_VIX(indx_B2)         = log_return_OD_extended_sort_lead(indx_B2);

return_OD_sort_lead_TC_VIX              = return_OD_extended_sort_lead_TC;
return_OD_long_TC_VIX                   = zeros(size(return_OD_extended_sort_lead_TC));
return_OD_long_TC_VIX(indx_B2)          = return_OD_sort_lead_TC_VIX(indx_B2);
cum_return_OD_long_TC_VIX               = cumprod(1+return_OD_long_TC_VIX);
log_return_OD_long_TC_VIX               = zeros(size(log_return_OD_extended_sort_lead_TC));
log_return_OD_long_TC_VIX(indx_B2)      = log_return_OD_extended_sort_lead_TC(indx_B2);

return_OD_sort_lead_RSV_VIX             = return_OD_extended_sort_lead;
return_OD_long_RSV_VIX                  = zeros(size(return_OD_extended_sort_lead));
return_OD_long_RSV_VIX(indx_B9)         = return_OD_sort_lead_RSV_VIX(indx_B9);
cum_return_OD_long_RSV_VIX              = cumprod(1+return_OD_long_RSV_VIX);
log_return_OD_long_RSV_VIX              = zeros(size(log_return_OD_extended_sort_lead));
log_return_OD_long_RSV_VIX(indx_B9)     = log_return_OD_extended_sort_lead(indx_B9);

return_OD_sort_lead_TC_RSV_VIX          = return_OD_extended_sort_lead_TC;
return_OD_long_TC_RSV_VIX               = zeros(size(return_OD_extended_sort_lead_TC));
return_OD_long_TC_RSV_VIX(indx_B9)      = return_OD_sort_lead_TC_RSV_VIX(indx_B9);
cum_return_OD_long_TC_RSV_VIX           = cumprod(1+return_OD_long_TC_RSV_VIX);
log_return_OD_long_TC_RSV_VIX           = zeros(size(log_return_OD_extended_sort_lead_TC));
log_return_OD_long_TC_RSV_VIX(indx_B9)  = log_return_OD_extended_sort_lead_TC(indx_B9);


%% return plots
% -cum returns - no trading costs ----------------------------------

LW  = 3;

figure;
plot(caldt_true_lead , cum_return_CTC,'Linestyle','-','Linewidth',LW,'Color','green');
hold on
plot(dates_yield_plot , cum_return_rf,'Linestyle','-','Linewidth',LW,'Color','black');
hold on
plot(caldt_true_lead , cum_return_OD,'Linestyle','-','Linewidth',LW,'Color','cyan');
hold on
plot(caldt_true_lead , cum_return_OD_extended,'Linestyle','-','Linewidth',LW,'Color','blue');
hold on
plot(caldt_true_lead , cum_return_OD_long_RSV,'Linestyle','-','Linewidth',LW,'Color','magenta');
legend('CTC','RF (4W US T-Bill)','OD: 02:00-3:00', 'OD+: 01:30-3:30', 'Buy the Dip: 01:30-3:30','Location','NorthWest')
xlabel('Year' )
ylabel('Cumulative Returns to $1 Investment' )
datetick('x',11)
xlim([min(caldt)-66 max(caldt)+66])
grid off

% -cum returns - with trading costs ----------------------------------
figure;
plot(caldt_true_lead , cum_return_CTC,'Linestyle','-','Linewidth',LW,'Color','green');
hold on
plot(dates_yield_plot , cum_return_rf,'Linestyle','-','Linewidth',LW,'Color','black');
hold on
plot(caldt_true_lead , cum_return_OD_TC,'Linestyle','-','Linewidth',LW,'Color','cyan');
hold on
plot(caldt_true_lead , cum_return_OD_extended_TC,'Linestyle','-','Linewidth',LW,'Color','blue');
hold on
plot(caldt_true_lead , cum_return_OD_long_TC_RSV,'Linestyle','-','Linewidth',LW,'Color','magenta');
legend('CTC','RF (4W US T-Bill)','OD: 02:00-3:00', 'OD+: 01:30-3:30', 'Buy the Dip: 01:30-3:30','Location','NorthWest')
xlabel('Year' )
ylabel('Cumulative Returns to $1 Investment' )
datetick('x',11)
xlim([min(caldt)-66 max(caldt)+66])
grid off



